<template>
  <common-page
    ref="commonPage"
    :bg-path="bgPath"
    :web-path="webPath"
    :columns="columns"
    :search-items="searchItems"
    :form-items="formItems"
    :editor-items="editorItems"
  />
</template>
<script>
export default {
  data() {
    return {
      // ===== ===== ===== ===== 全局属性 ===== ===== ===== =====
      // 后台接口路径
      bgPath: 'health/content/content/guidance',
      // Web路径
      webPath: 'health/content/content/Guidance',
      // ===== ===== ===== ===== 页面配置 ===== ===== ===== =====
      // 搜索内容
      searchItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "id",
              name: "ID",
              span: 6,
              type: "id",
              config: {
                edit: false
              }
            },
            {
              code: "code",
              name: "编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "name",
              name: "名称",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "labelNameGroup",
              name: "标签组",
              type: "group",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "infoTypeCode",
              name: "类型编码",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "infoTypeName",
              name: "类型名称",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "contentInfoCode",
              name: "内容信息编码",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "contentInfoName",
              name: "内容信息名称",
              type: "text",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "minReleaseTime",
              name: "最早发布时间",
              type: "datetime",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "maxReleaseTime",
              name: "最晚发布时间",
              type: "datetime",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "homeSign",
              name: "首页标识",
              type: "select",
              span: 6,
              config: {
                edit: false,
                keyField: "key",
                valueField: "value",
                options: [
                  { key: "0", value: "否" },
                  { key: "1", value: "是" }
                ]
              }
            },
            {
              code: "topSign",
              name: "置顶标识",
              type: "select",
              span: 6,
              config: {
                edit: false,
                keyField: "key",
                valueField: "value",
                options: [
                  { key: "0", value: "否" },
                  { key: "1", value: "是" }
                ]
              }
            },
            {
              code: "publicSign",
              name: "公开标识",
              type: "select",
              span: 6,
              config: {
                edit: false,
                keyField: "key",
                valueField: "value",
                options: [
                  { key: "0", value: "否" },
                  { key: "1", value: "是" }
                ]
              }
            }
          ]
        }
      ],
      // 列表内容
      columns: [
        {
          code: "id",
          name: "ID",
          type: "id",
          config: {
            edit: false
          }
        },
        {
          code: "code",
          name: "编码",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "name",
          name: "名称",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "conKeyword",
          name: "关键词",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "conDescribe",
          name: "内容描述",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "labelGroup",
          name: "标签组",
          type: "group",
          config: {
            edit: false
          }
        },
        {
          code: "typeCode",
          name: "类型编码",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "typeName",
          name: "类型名称",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "contentInfoCode",
          name: "内容信息编码",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "coverImg",
          name: "封面图片地址",
          type: "oss",
          config: {
            edit: false
          }
        },
        {
          code: "content",
          name: "内容",
          type: "editor",
          config: {
            edit: false
          }
        }, {
          code: "robotContent",
          name: "机器人内容",
          type: "editor",
          config: {
            edit: false
          }
        },
        {
          code: "padContent",
          name: "PAD内容",
          type: "editor",
          config: {
            edit: false
          }
        },
        {
          code: "htmlContent",
          name: "HTML内容",
          type: "editor",
          config: {
            edit: false
          }
        },
        {
          code: "pcContent",
          name: "PC内容",
          type: "editor",
          config: {
            edit: false
          }
        },
        {
          code: "releaseTime",
          name: "发布时间",
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "homeSign",
          name: "首页标识",
          type: "select",
          config: {
            edit: false,
            keyField: "key",
            valueField: "value",
            options: [
              { key: "0", value: "否" },
              { key: "1", value: "是" }
            ]
          }
        },
        {
          code: "topSign",
          name: "置顶标识",
          type: "select",
          config: {
            edit: false,
            keyField: "key",
            valueField: "value",
            options: [
              { key: "0", value: "否" },
              { key: "1", value: "是" }
            ]
          }
        },
        {
          code: "publicSign",
          name: "公开标识",
          type: "select",
          config: {
            edit: false,
            keyField: "key",
            valueField: "value",
            options: [
              { key: "0", value: "否" },
              { key: "1", value: "是" }
            ]
          }
        },
        {
          code: "contentWeight",
          name: "内容权重",
          type: "number",
          config: {
            edit: false,
            precision: 2
          }
        }
      ],
      // 增加/修改/详情 表单
      formItems: [
        {
          rowIndex: 1,
          items: [

            {
              code: "id",
              name: "ID",
              type: "id",
              span: 6,
              config: {
                edit: false
              }
            },
            {
              code: "code",
              name: "编码",
              type: "text",
              span: 6,
              config: {
                edit: false,
                require: true
              }
            },
            {
              code: "name",
              name: "名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                require: true
              }
            },
            {
              code: "conKeyword",
              name: "关键词",
              type: "text",
              span: 6,
              config: {
                edit: false,
                require: false
              }
            },
            {
              code: "conDescribe",
              name: "内容描述",
              type: "text",
              span: 6,
              config: {
                edit: false,
                require: false
              }
            },
            {
              code: "labelGroup",
              name: "标签组",
              type: "group",
              span: 6,
              config: {
                edit: false,
                require: false
              }
            },
            {
              code: "typeCode",
              span: 6,
              name: "类型编码",
              type: "popup",
              config: {
                url: "health/content/content/guidancetype",
                filedList: [
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                required: true
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  const formData = {
                    typeName: row.name,
                    typeCode: row.code,
                    typeId: row.id
                  }
                  this.$refs.commonPage.updateFormData(formData)
                }
              }
            },
            {
              code: "typeName",
              name: "类型名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                require: false,
                disabled: true
              }
            },
            {
              code: "contentInfoCode",
              span: 6,
              name: "内容信息编码",
              type: "popup",
              config: {
                url: "health/content/label/contentinfo",
                filedList: [
                  { code: 'code', name: '编码' },
                  { code: 'conName', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                required: true
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  console.log(row)
                  const formData = {
                    contentInfoCode: row.code,
                    contentInfoId: row.id
                  }
                  this.$refs.commonPage.updateFormData(formData)
                }
              }
            },
            {
              code: "coverImg",
              name: "封面图片地址",
              span: 6,
              type: "oss",
              config: {
                edit: false
              }
            },
            {
              code: "releaseTime",
              name: "发布时间",
              type: "datetime",
              span: 6,
              config: {
                edit: false,
                require: false,
                disabled: false
              }
            },
            {
              code: "homeSign",
              name: "首页标识",
              type: "select",
              span: 6,
              config: {
                edit: false,
                keyField: "key",
                valueField: "value",
                options: [
                  { key: "0", value: "否" },
                  { key: "1", value: "是" }
                ]
              }
            },
            {
              code: "topSign",
              name: "置顶标识",
              type: "select",
              span: 6,
              config: {
                edit: false,
                keyField: "key",
                valueField: "value",
                options: [
                  { key: "0", value: "否" },
                  { key: "1", value: "是" }
                ]
              }
            },
            {
              code: "publicSign",
              name: "公开标识",
              type: "select",
              span: 6,
              config: {
                edit: false,
                keyField: "key",
                valueField: "value",
                options: [
                  { key: "0", value: "否" },
                  { key: "1", value: "是" }
                ]
              }
            },
            {
              code: "contentWeight",
              name: "内容权重",
              type: "number",
              span: 6,
              config: {
                edit: false,
                precision: 2
              }
            }
          ]
        }
      ],
      // 富文本编辑器
      editorItems: [
        {
          key: "content",
          name: "内容"
        },
        {
          key: "robotContent",
          name: "机器人内容"
        }, {
          key: "padContent",
          name: "PAD内容"
        }, {
          key: "htmlContent",
          name: "HTML内容"
        }, {
          key: "pcContent",
          name: "PC内容"
        }
      ]
    }
  }
}
</script>
